import React, {PureComponent} from 'react'
import BasePie from '../../component/chart/base-pie'
import {connect} from 'react-redux'
import {setTitle, scale} from '../chart/util/common'

class Pie extends PureComponent {
    shouldComponentUpdate(nextProps) {
        return nextProps.exceptionStat !== this.props.exceptionStat
    }

    renderDate = (data) => {
        const exceptionStat = data.toJS()
        return {
            title: '问题处理概况',
            option: {
                title: {
                    textStyle: {
                        color: '#5BE2EF',
                        fontSize: 14 * scale,
                        fontWeight: 'bolder'
                    }
                }
            },
            data: [{
                value: (exceptionStat.Unprocessed || 0) * 100,
                name: '未处理'
            }, {
                value: (exceptionStat.Processed || 0) * 100,
                name: '已处理'
            },]
        }
    }

    render() {
        const {exceptionStat} = this.props
        const data = this.renderDate(exceptionStat)
        return (
            <BasePie config={data}/>
        )
    }

}


function mapStoreToProps({exceptionStat}) {
    return {
        exceptionStat
    }
}

export default connect(mapStoreToProps)(Pie)